const withOffline = require('next-offline')
const withCss = require('@zeit/next-css')
const withImages = require('next-images')
const withSass = require('@zeit/next-sass')
const withPlugins = require("next-compose-plugins")
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin')

// fix: prevents error when .css files are required by node
if (typeof require !== 'undefined') {
  require.extensions['.css'] = (file) => {}
  require.extensions['.scss'] = (file) => {}
}

module.exports = withPlugins([[withOffline], [withCss], [withSass, {cssModules: true, cssLoaderOptions: {importLoaders: 1, localIdentName: "[hash:base64:12]"}}], [withImages]], {
  webpack: (config) => {
    const newConfig = { ...config }
    newConfig.plugins = [
      ...config.plugins,
      new FilterWarningsPlugin({
        exclude: /mini-css-extract-plugin[^]*Conflicting order between:/
      })
    ]
    return newConfig
  }
})